package cn.iocoder.yudao.module.member.user.convert;

import cn.iocoder.yudao.framework.region.RegionUtils;
import cn.iocoder.yudao.framework.region.enums.RegionDataSet;
import cn.iocoder.yudao.module.member.user.dal.dataobject.MemberUserDO;
import cn.iocoder.yudao.module.member.user.vo.MemberUserRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @see AuthConvert
 * @since 2024/11/29
 */
@Mapper
public interface UserConvert {

    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    @Mapping(source = "areaId", target = "countyCode")
    @Mapping(source = "cityId", target = "cityCode")
    @Mapping(source = "provinceId", target = "provinceCode")
    MemberUserRespVO convert(MemberUserDO bean);

    default MemberUserRespVO convertIncludeRegion(MemberUserDO bean) {
        MemberUserRespVO respVO = convert(bean);
        RegionUtils.autoAssignCounty(RegionDataSet.ONLY_LATEST, respVO.getCountyCode(), respVO);
        return respVO;
    }

}
